from pygame.locals import KEYDOWN
import pygame


def event_loop(handle_key,delay=10):
    while True:
        pygame.event.pump()
        event=pygame.event.poll()
        if event.type==KEYDOWN:
            handle_key(ascii(event.key))
        pygame.time.delay(delay)


if __name__=='__main__':
    pygame.init()
    pygame.display.set_mode((400,300))
    pygame.display.set_caption("弹出的窗口")
    event_loop(print)
